package ch.ricosoft.hr.sorter;

import ch.ricosoft.hr.Team;

public final class TotalPointSorter extends InfoSorter {
	public int compare(Team o1, Team o2) {
		int diff = o2.getHomePoints() + o2.getOutwardPoints()
				- o1.getOutwardPoints() - o1.getHomePoints();
		if (diff == 0) {
			diff = o2.getHomeDiff() + o2.getOutwardDiff()
					- o1.getOutwardDiff() - o1.getHomeDiff();
			if (diff == 0) {
				diff = o2.getHomeMade() + o2.getOutwardMade()
						- o1.getOutwardMade() - o1.getHomeMade();
			}
		}
		return diff;
	}

	@Override
	public int getWins(Team t) {
		return t.getHomeWin() + t.getOutwardWin();
	}

	@Override
	public int getDraws(Team t) {
		return t.getHomeDraw() + t.getOutwardDraw();
	}

	@Override
	public int getLoss(Team t) {
		return t.getHomeLoss() + t.getOutwardLoss();
	}

	@Override
	public int getMade(Team t) {
		return t.getHomeMade() + t.getOutwardMade();
	}

	@Override
	public int getGotten(Team t) {
		return t.getHomeGotten() + t.getOutwardGotten();
	}

	@Override
	public int getDiff(Team t) {
		return t.getHomeDiff() + t.getOutwardDiff();
	}

	@Override
	public int getPoints(Team t) {
		return t.getHomePoints() + t.getOutwardPoints();
	}

	@Override
	public int getLossPoints(Team t) {
		return t.getHomeLossPoints() + t.getOutwardLossPoints();
	}
}